﻿package {
	import flash.display.*;
	import flash.events.*;
	
	import idv.cjcat.display.*;
	import idv.cjcat.display.dynashape.*;
	
	public class Main extends Sprite {
		
		public function Main():void {
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			var mt:MouseTracker = new MouseTracker(root);
			var mtX0:MouseTracker = new MouseTracker(root, true, false, 0, 0);
			var mtX400:MouseTracker = new MouseTracker(root, true, false, 400, 400);
			var mtY0:MouseTracker = new MouseTracker(root, false, true, 0, 0);
			var mtY400:MouseTracker = new MouseTracker(root, false, true, 400, 400);
			var ds:DynaShape = new DynaShape();
			var cross1:DynaGraphics = new DynaGraphics();
			var cross2:DynaGraphics = new DynaGraphics();
			var blackLine:LineStyle = new LineStyle(2, 0x000000);
			var greyLine:LineStyle = new LineStyle(2, 0xCCCCCC);
			
			cross1.lineStyle(blackLine);
			cross1.lineTo(mt);
			cross1.lineTo( { x:400, y:0 } );
			cross1.moveTo( { x:400, y:400 } );
			cross1.lineTo(mt);
			cross1.lineTo( { x:0, y:400 } );
			
			cross2.lineStyle(greyLine);
			cross2.moveTo(mtX0);
			cross2.lineTo(mtX400);
			cross2.moveTo(mtY0);
			cross2.lineTo(mtY400);
			
			ds.add(cross1);
			ds.add(cross2);
			addChild(ds);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, ds.render);
		}
		
	}
	
}